package com.ydy.quartz.job;

import com.ydy.quartz.util.SpringUtils;
import com.ydy.quartz.service.MailService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class SendMailJob implements Job {

    @Autowired
    private MailService mailService;

    private static Logger LOGGER = LoggerFactory.getLogger(SendMailJob.class);

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        LOGGER.info("调用时间{}，参数{}", LocalDateTime.now(),context);
        mailService = SpringUtils.getBean(MailService.class);
        mailService.sendAttachmentsMail("SpringBoot+Quartz+Mail","测试邮件"
,"\\springcloud-study\\springcloud-study\\ydy-destined\\尹家村.jpg","");
        LOGGER.info("");
    }
}
